// src/services/request.js
import {
	API_CONFIG
} from '@/utils/interceptors.js'
// 初始化请求配置
uni.$u.http.setConfig((config) => {
	config.baseUrl = API_CONFIG.baseUrl
	config.timeout = API_CONFIG.timeout
	return config
})

// 封装请求方法
export const request = (options) => {
	return uni.$u.http.request(options)
}

// 封装GET请求
export const get = (url, data = {}, config = {}) => {
	return request({
		url,
		method: 'GET',
		params: data,
		...config
	})
}

// 封装POST请求
export const post = (url, data = {}, config = {}) => {
	return request({
		url,
		method: 'POST',
		data,
		...config
	})
}

// 封装PUT请求
export const put = (url, data = {}, config = {}) => {
	return request({
		url,
		method: 'PUT',
		data,
		...config
	})
}

// 封装DELETE请求
export const del = (url, data = {}, config = {}) => {
	return request({
		url,
		method: 'DELETE',
		data,
		...config
	})
}